package com.marvels.approve.credit.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.approve.credit.dto.IntBankBanruDetailDTO;
import com.marvels.approve.credit.dto.IntBankBasiInfoCollectionDTO;
import com.marvels.approve.credit.dto.IntBankBasicDTO;
import com.marvels.approve.credit.dto.IntBankCreditCardDTO;
import com.marvels.approve.credit.dto.IntBankCreditPaymentRecordsDTO;
import com.marvels.approve.credit.dto.IntBankCredittipsDTO;
import com.marvels.approve.credit.dto.IntBankDwellmessageDTO;
import com.marvels.approve.credit.dto.IntBankEndowmentInsuranceDTO;
import com.marvels.approve.credit.dto.IntBankGuaranteeCountDTO;
import com.marvels.approve.credit.dto.IntBankNotCredittipsDTO;
import com.marvels.approve.credit.dto.IntBankNotPinshouseholdsDTO;
import com.marvels.approve.credit.dto.IntBankNotQuasiCreditDTO;
import com.marvels.approve.credit.dto.IntBankPositionmesageDTO;
import com.marvels.approve.credit.dto.IntBankQueryDetailDTO;
import com.marvels.approve.credit.dto.IntBankQuerySummaryDTO;
import com.marvels.approve.credit.dto.IntBankStandardCreditCardDTO;
import com.marvels.approve.credit.dto.IntBankTotalDTO;
import com.marvels.approve.credit.service.IntBankService;
import com.marvels.approve.process.dto.LoanApplyCaseDTO;
import com.marvels.approve.process.service.AttachmentInfoService;
import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;

@RestController
@RequestMapping("/approve/credit/intbank/service")
public class ApproveIntBankController {

	@Autowired
	private IntBankService intBankService;
	
	@Autowired
	private AttachmentInfoService attachmentInfoService;

	/**
	 * 查询征信报告
	 * 
	 * @param param
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("checktheCreditReport")
	@ResponseBody
	public MarvelsResultDTO checktheCreditReport(@RequestBody(required = false) LoanApplyCaseDTO param)
			throws MarvelsBusinessException {
		IntBankBasiInfoCollectionDTO intBankBasiInfoCollection = null;
		try {
			intBankBasiInfoCollection = intBankService.checktheCreditReport(param);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				intBankBasiInfoCollection);
	}

	/**
	 * 提交
	 * 
	 * @param param
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("submitState")
	@ResponseBody
	public MarvelsResultDTO submitState(@RequestBody(required = false) LoanApplyCaseDTO param)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.submitState(param.getLoanId(), param.getCustCardNo());
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 征信否决
	 * 
	 * @param param
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("rejectOperating")
	@ResponseBody
	public MarvelsResultDTO rejectOperating(@RequestBody(required = false) LoanApplyCaseDTO param)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.rejectOperating(param.getLoanId());
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 征信退回
	 * 
	 * @param param
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("returnedOperating")
	@ResponseBody
	public MarvelsResultDTO returnedOperating(@RequestBody(required = false) LoanApplyCaseDTO param)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.returnedOperating(param.getLoanId());
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	@RequestMapping("saveIntBankBasicList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankBasicList(@RequestBody IntBankBasicDTO param) throws MarvelsBusinessException {
		IntBankBasicDTO data;
		try {
			data = intBankService.saveIntBankBasicList(param);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 修改或增加居住信息
	 * 
	 * @param addIntBankDwellmessage
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankDwellmessage")
	@ResponseBody
	public MarvelsResultDTO saveIntBankDwellmessage(@RequestBody IntBankDwellmessageDTO addIntBankDwellmessage)
			throws MarvelsBusinessException {
		IntBankDwellmessageDTO data = null;
		try {
			data = intBankService.saveIntBankDwellmessage(addIntBankDwellmessage);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 修改或增加职业信息
	 * 
	 * @param intBankPositionmesage
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankPositionmesage")
	@ResponseBody
	public MarvelsResultDTO saveIntBankPositionmesage(@RequestBody IntBankPositionmesageDTO intBankPositionmesage)
			throws MarvelsBusinessException {
		IntBankPositionmesageDTO data = null;
		try {
			data = intBankService.addProfession(intBankPositionmesage);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 修改信用提示
	 * 
	 * @param intBankCredittips
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankCredittipsList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankCredittipsList(@RequestBody IntBankCredittipsDTO intBankCredittips)
			throws MarvelsBusinessException {
		IntBankCredittipsDTO data = null;
		try {
			data = intBankService.updateCredittips(intBankCredittips);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 未销户准贷记卡信息汇总保存
	 * 
	 * @param intBankNotQuasiCredit
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankNotQuasiCreditList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankNotQuasiCreditList(@RequestBody IntBankNotQuasiCreditDTO intBankNotQuasiCredit)
			throws MarvelsBusinessException {
		IntBankNotQuasiCreditDTO data = null;
		try {
			data = intBankService.updateQuasiCredit(intBankNotQuasiCredit);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 修改未结清贷款信息汇总
	 * 
	 * @param intBankNotCredittips
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankNotCredittipsList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankNotCredittipsList(@RequestBody IntBankNotCredittipsDTO intBankNotCredittips)
			throws MarvelsBusinessException {
		IntBankNotCredittipsDTO data = null;
		try {
			data = intBankService.updateIntBankNotCredittips(intBankNotCredittips);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 修改未销户贷记卡信息汇总
	 * 
	 * @param intBankNotPinshouseholds
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankNotPinshouseholdsList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankNotPinshouseholdsList(
			@RequestBody IntBankNotPinshouseholdsDTO intBankNotPinshouseholds) throws MarvelsBusinessException {
		IntBankNotPinshouseholdsDTO data = null;
		try {
			data = intBankService.updateIntBankNotPinshouseholds(intBankNotPinshouseholds);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 编辑对外担保信息汇总
	 * 
	 * @param intBankGuaranteeCount
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankGuaranteeCountList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankGuaranteeCountList(@RequestBody IntBankGuaranteeCountDTO intBankGuaranteeCount)
			throws MarvelsBusinessException {
		IntBankGuaranteeCountDTO data = null;
		try {
			data = intBankService.updateGuaranteeCount(intBankGuaranteeCount);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 贷款 增加
	 * 
	 * @param intBankCreditPaymentRecords
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankCreditPaymentRecordsList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankCreditPaymentRecordsList(
			@RequestBody IntBankCreditPaymentRecordsDTO intBankCreditPaymentRecord) throws MarvelsBusinessException {
		List<IntBankCreditPaymentRecordsDTO> data = null;
		try {
			data = intBankService.saveIntBankCreditPaymentRecord(intBankCreditPaymentRecord);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 贷款修改
	 * 
	 * @param intBankCreditPaymentRecords
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("updatIntBankCreditPaymentRecordsList")
	@ResponseBody
	public MarvelsResultDTO updatIntBankCreditPaymentRecordsList(
			@RequestBody(required = false) IntBankCreditPaymentRecordsDTO intBankCreditPaymentRecords)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.updateRecord(intBankCreditPaymentRecords);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("贷款修改异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 贷记卡增加
	 * 
	 * @param intBankCreditCard
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankCreditCard")
	@ResponseBody
	public MarvelsResultDTO saveIntBankCreditCard(@RequestBody IntBankCreditCardDTO intBankCreditCard)
			throws MarvelsBusinessException {
		List<IntBankCreditCardDTO> data = null;
		try {
			data = intBankService.saveCreditCard(intBankCreditCard);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 贷记卡修改
	 * 
	 * @param intBankCreditCard
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("updateIntBankCreditCard")
	@ResponseBody
	public MarvelsResultDTO updateIntBankCreditCard(
			@RequestBody(required = false) IntBankCreditCardDTO intBankCreditCard) throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.updateCredit(intBankCreditCard);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("贷记卡修改异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 准贷记卡增加
	 * 
	 * @param intBankStandardCreditCard
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankStandardCreditCardsList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankStandardCreditCardsList(
			@RequestBody IntBankStandardCreditCardDTO intBankStandardCreditCard) throws MarvelsBusinessException {
		List<IntBankStandardCreditCardDTO> data = null;
		try {
			data = intBankService.saveStandardCreditCard(intBankStandardCreditCard);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 准贷记卡修改
	 * 
	 * @param intBankStandardCreditCard
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("updateIntBankStandardCreditCardsList")
	@ResponseBody
	public MarvelsResultDTO updateIntBankStandardCreditCardsList(
			@RequestBody(required = false) IntBankStandardCreditCardDTO intBankStandardCreditCard)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.updateStandardCredit(intBankStandardCreditCard);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("准贷记卡修改异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 修改 或 添加 养老保险金数据
	 * 
	 * @param intBankStandardCreditCard
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankEndowmentInsuranceList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankEndowmentInsuranceList(
			@RequestBody IntBankEndowmentInsuranceDTO intBankEndowmentInsurance) throws MarvelsBusinessException {
		IntBankEndowmentInsuranceDTO data;
		try {
			data = intBankService.saveIntBankEndowmentInsurance(intBankEndowmentInsurance);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("修改 或 添加 养老保险金数据异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 查询记录增加
	 * 
	 * @param intBankQueryDetail
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankBanruDetail")
	@ResponseBody
	public MarvelsResultDTO saveIntBankBanruDetail(@RequestBody IntBankBanruDetailDTO intBankBanruDetail)
			throws MarvelsBusinessException {
		List<IntBankBanruDetailDTO> data = null;
		try {
			data = intBankService.saveIntBankBanruDetail(intBankBanruDetail);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 保存查询记录
	 * 
	 * @param intBankBanruDetail
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankQueryDetail")
	@ResponseBody
	public MarvelsResultDTO saveIntBankQueryDetail(@RequestBody IntBankQueryDetailDTO intBankQueryDetail)
			throws MarvelsBusinessException {
		List<IntBankQueryDetailDTO> data = null;
		try {
			data = intBankService.saveIntBankQueryDetail(intBankQueryDetail);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 修改查询记录汇总
	 * 
	 * @param intBankQuerySummary
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveIntBankQuerySummaryList")
	@ResponseBody
	public MarvelsResultDTO saveIntBankQuerySummaryList(@RequestBody IntBankQuerySummaryDTO intBankQuerySummary)
			throws MarvelsBusinessException {
		IntBankQuerySummaryDTO data = null;
		try {
			data = intBankService.saveIntBankQuerySummary(intBankQuerySummary);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("修改查询记录汇总异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				data);
	}

	/**
	 * 删除个人查询记录
	 * 
	 * @param intBankBanruDetail
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("deleteBanruDetail")
	@ResponseBody
	public MarvelsResultDTO deleteBanruDetail(@RequestBody IntBankBanruDetailDTO intBankBanruDetail)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.deleteBanruDetail(intBankBanruDetail);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 删除记录
	 * 
	 * @param intBankQuerySummary
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("deleteQueryDetail")
	@ResponseBody
	public MarvelsResultDTO deleteQueryDetail(@RequestBody IntBankQueryDetailDTO intBankQueryDetail)
			throws MarvelsBusinessException {
		Integer count;
		try {
			count = intBankService.deleteQueryDetail(intBankQueryDetail);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				count);
	}

	/**
	 * 一键保存
	 * 
	 * @param intBankTotalDto
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("saveAllForm")
	@ResponseBody
	public MarvelsResultDTO saveAllForm(@RequestBody IntBankTotalDTO intBankTotalDto) throws MarvelsBusinessException {
		try {
			intBankService.saveAllForm(intBankTotalDto);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				null);
	}

	@RequestMapping("submitCreditReport/{loanId}")
	@ResponseBody
	public MarvelsResultDTO submitCreditReport(@PathVariable("loanId") String loanId) throws MarvelsBusinessException {
		try {
			return intBankService.submitCreditReport(loanId);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
	}
	
	@RequestMapping("returnCreditReport/{loanId}")
	@ResponseBody
	public MarvelsResultDTO returnCreditReport(@PathVariable("loanId") String loanId) throws MarvelsBusinessException {
		try {
			intBankService.returnCreditReport(loanId);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
				null);
	}
	
	@RequestMapping("loadAttachmentById/{id}")
	@ResponseBody
	public void loadAttachmentById(@PathVariable("id") Long id,HttpServletRequest request,HttpServletResponse response){
		try {
			attachmentInfoService.loadAttachmentById(id, request, response);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("征信报告审核 读取附件异常, 附件id="+id, e);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error("征信报告审核 读取附件异常, 附件id="+id, e);
		}
	}
}
